package com.yunfeisoft.business.service.impl;

import com.yunfeisoft.business.dao.inter.ElderHealthQuestionDao;
import com.yunfeisoft.business.model.ElderHealthQuestion;
import com.yunfeisoft.business.service.inter.ElderHealthQuestionService;
import com.yunfeisoft.common.base.BaseServiceImpl;
import com.yunfeisoft.common.sql.separation.DataSourceChange;
import com.yunfeisoft.common.utils.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * ClassName: ElderHealthQuestionServiceImpl
 * Description: 现存主要健康问题从表service实现
 * Author: Jackie liu
 * Date: 2020-04-04
 */
@Service("elderHealthQuestionService")
public class ElderHealthQuestionServiceImpl extends BaseServiceImpl<ElderHealthQuestion, String, ElderHealthQuestionDao> implements ElderHealthQuestionService {

    @Override
    @DataSourceChange(slave = true)
    public Page<ElderHealthQuestion> queryPage(Map<String, Object> params) {
        return getDao().queryPage(params);
    }

    @Override
    public ElderHealthQuestion getByHealthId(String elderHealthId) {
        return getDao().getByHealthId(elderHealthId);
    }

    @Override
    public void deleteByHealthId(String elderHealthId) {
        getDao().deleteByHealthId(elderHealthId);
    }

    @Transactional
    public void saveElderHealthQuestion(ElderHealthQuestion record) {
        // 先删除之前的记录
        getDao().deleteByHealthId(record.getElderHealthId());
        getDao().insert(record);
    }
}